<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/order_details.css')}}">
    <script src="{{mix('/js/pdfobject.min.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">订单详情</div>
                <div class="content">
                    <div class="order_state">
                        <ul class="order_finish">
                            <li class="order_first one">
                                <h3 class="submit">等待买家付款</h3>
                                <div class="spend">
                                    <p class="quan">1</p>
                                    <img class="quan1" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                    <img class="green" src="{{asset('/img/web/user/left.png')}}" alt="">
                                </div>
                                <h4 class="order_day order_day1">{{ $order['created_at'] }}</h4>
                            </li>
                            <li class="order_first second">
                                <h3 class="submit">等待卖家发货</h3>
                                <div class="spend">
                                    <p class="quan">2</p>
                                @if($order['order_status'] >= 2 && $order['order_status'] != 5)
                                        <img class="quan2" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                        <img class="green_1" src="{{asset('/img/web/user/left.png')}}" alt="">
                                        <img class="green2" src="{{asset('/img/web/user/right.png')}}" alt="">
                                </div>
                                <h4 class="order_day order_day2">{{ $order['shipments_at'] }}</h4>
                                @else
                                </div>
                                @endif
                            </li>
                            <li class="order_first third">
                                <h3 class="submit">等待买家确认收货</h3>
                                <div class="spend">
                                    <p class="quan">3</p>
                                @if($order['order_status'] >= 3 && $order['order_status'] != 5)
                                        <img class="quan3" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                        <img class="green_2" src="{{asset('/img/web/user/left.png')}}" alt="">
                                        <img class="green4" src="{{asset('/img/web/user/right.png')}}" alt="">
                                </div>
                                <h4 class="order_day order_day3">{{ $order['confirm_at'] }}</h4>
                                @else
                                </div>
                                @endif
                            </li>
                            <li class="order_first fourth">
                                <h3 class="submit">交易完成</h3>
                                <div class="spend">
                                    <p class="quan">4</p>
                                @if($order['order_status'] >= 4 && $order['order_status'] != 5)
                                        <img class="quan4" src="{{asset('/img/web/user/dui.png')}}" alt="">
                                        <img class="green3" src="{{asset('/img/web/user/right.png')}}" alt="">
                                </div>
                                <h4 class="order_day order_day4">{{ $order['confirm_at'] }}</h4>
                                @else
                                </div>
                                @endif
                            </li>
                        </ul>
                    </div>
                    <div class="order_state_box">当前订单状态：
                        @if($order['order_status'] == 1)
                        <font>订单已创建，等待买家付款</font>
                        <div class="trade_close fr" data-id="{{$order['id']}}">交易关闭</div>
                            @if($order['order_type'] != 4)
                                <div class="modify_price fr" data-id="{{$order['id']}}">修改价格</div>
                            @endif
                        @elseif($order['order_status'] == 2)
                        <font>买家已付款，等待卖家发货</font>
                        <div class="revise_price fr shipments_btn" data-id="{{$order['id']}}">发货</div>
                        @elseif($order['order_status'] == 3)
                        <font>卖家已发货，等待买家确认收货</font>
                        @elseif($order['order_status'] == 4)
                        <font>买家已确认收货，交易完成</font>
                        <div class="revise_evaluate fr" data-id="{{$order['id']}}">{{$order['seller_comment_status'] ? '查看评价' : '评价'}}</div>
                        @elseif($order['order_status'] == 5)
                        <font>订单已取消</font>
                        <div class="fr cause_closure" data-id="{{$order['id']}}">关闭原因：{{$order['cancel_reason'] ? $order['cancel_reason_name'] : '买家关闭'}}</div>
                        @endif
                        <!-- <div class="revise_evaluate fr" data-id="{{$order['id']}}">评价</div>
                        <div class="revise_price fr" data-id="1">发货</div> -->
                    </div>

                    <div class="information_box">
                        <div class="left_box">
                            <h2>收货信息</h2>
                            <div class="tit">订单号：{{$order['order_code']}}</div>
                            <div class="tit">付款金额：{{$order['order_money']}} 元</div>
                            <div class="tit">收货人：{{$order['receiver']}}</div>
                            <div class="tit">收货地址：{{$order['address']}}</div>
                            <div class="tit">手机：{{$order['phone']}}</div>
                        </div>
                        <div class="left_box border_l">
                            <h2>买家信息</h2>
                            <div class="tit">会员登录名：{{array_get($order,'user.name')}}</div>
                            <div class="tit">付款帐号：6225 8541 2541 28(C) </div>
                            <div class="tit">姓名：{{$order['receiver']}}</div>
                            <div class="tit">手机：{{array_get($order,'user.phone')}}</div>
                            <div class="tit">帐号类型：@if(array_get($order,'user.personal_enterprise')==1) 企业账户 @else 个人账户 @endif</div>
                        </div>
                    </div>

                    @if($order['order_status'] >= 2)
                    <div class="information_box">
                        <div class="left_box">
                            <h2>物流信息</h2>
                            @if($order['order_express'])
                            <div class="tit">物流单号：{{array_get($order,'order_express.waybill_number')}}</div>
                            <div class="tit">物流公司：{{array_get($order,'order_express.express_company')}}</div>
                            <div class="tit">物流详情：<div class="btn_seeLogistics" data-id="{{$order['id']}}">查看物流</div></div>
                            @else
                            <div class="tit">暂无该笔订单的物流信息</div>
                            @endif
                        </div>
                        <div class="left_box border_l">
                            <h2>合同信息</h2>
                            <div class="tit">合同编号：{{array_get($order,'user_contracts.contracts_code')}}</div>
                            <div class="tit">模板名称：{{array_get($order,'user_contracts.contracts_name')}}</div>
                            <div class="tit">合同详情：<div class="btn_contract" data-id="1">查看合同</div></div>
                        </div>
                    </div>
                    @endif

                    <div class="table_list">
                        <table>
                            <thead>
                                <tr>
                                    <th width="90"></th>
                                    <th width="300">
                                        <span>货品</span>
                                    </th>
                                    <th>单价</th>
                                    <th>数量</th>
                                    <th>优惠</th>
                                    <th>
                                        @if($order['order_type']==1 || $order['order_type']==6)
                                        运费
                                        @else
                                        备注
                                        @endif
                                    </th>
                                    <th>小计</th>
                                </tr>
                            </thead>
                            <tbody>
                            @if($order['order_type']==1 || $order['order_type']==6)

                                @foreach(array_get($order,'order_products') as $key=>$product)
                                <tr>
                                    <td>
                                        <a class="img" target="_blank" href="/product/info/{{$product['product_id']}}/{{$product['sku_id']}}">
                                          <img width="70" height="70" src="{{$product['product_img_url']}}">
                                        </a>
                                    </td>
                                    <td class="text-left">
                                        <span class="goodsname">
                                          <a target="_blank" href="/product/info/{{$product['product_id']}}/{{$product['sku_id']}}">{{$product['product_name']}}</a>
                                        </span>
                                    </td>
                                    <td>¥{{$product['product_price']}}</td>
                                    <td>×{{$product['quantity']}}</td>
                                    <td>¥{{$product['discount_money']}}</td>

                                    @if($key == 0)
                                       <td class = "product-name" width="130" height="126" rowspan="{{count($order['order_products'])}}">运费：￥{{$order['freight']?:'0.00'}}</td>
                                       <td class = "product-name product-price" width="160" height="126" rowspan="{{count($order['order_products'])}}" style="color: red;">￥{{$order['order_money']}}</td>
                                   @endif

                                </tr>
                                @endforeach

                            @elseif($order['order_type']==4)
                                @foreach(array_get($order,'items_products') as $key=>$items_product)
                                <tr>
                                    <td>
                                        {{$items_product['product_name']}}

                                    </td>
                                    <td class="text-left">
                                        <span class="goodsname">
                                            {{$items_product['brand']}} {{$items_product['model']}}
                                        </span>
                                    </td>
                                    <td>¥{{$items_product['price']}}</td>
                                    <td>×{{$items_product['num']}}</td>
                                    <td>¥{{$items_product['total_price']}}</td>

                                    @if($key == 0)
                                       <td class = "product-name" width="130" height="126" rowspan="{{count($order['order_products'])}}">
                                           {{in_array(1,$order['items_information']['quote_contain'])?'含票税':''}}    {{in_array(2,$order['items_information']['quote_contain'])?'含运费':''}}    {{in_array(3,$order['items_information']['quote_contain'])?'含安装':''}}    {{in_array(4,$order['items_information']['quote_contain'])?'含公报总价':''}}
                                       </td>
                                       <td class = "product-name product-price" width="160" height="126" rowspan="{{count($order['order_products'])}}" style="color: red;">￥{{$order['order_money']}}</td>
                                   @endif

                                </tr>
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="leavingmessage_box">
                        <div class="tit">买家留言：{{$order['remark']}}</div>
                    </div>
                    <div class="back_box">
                        <a href="{{asset('/member/seller/orders')}}" class="back">返回</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="bg_h"></div>

<div class="contract_bombbox">
    <div class="message" style="margin-top: 20px;"><span>合同编号：</span>{{array_get($order,'user_contracts.contracts_code')}} </div>
    <div class="message"><span>模板名称：</span>{{array_get($order,'user_contracts.contracts_name')}}</div>
    <div class="message">
        <span>合同详情：</span>
        <div class="contract_right">
            <pre style="white-space: pre-line;">{{array_get($order,'user_contracts.content')}}</pre>
        </div>
    </div>
    <div class="message">
        <div class="sub close_box">确认</div>
    </div>
</div>
{{--修改价格--}}
<div class="revise_price_bombbox">
    <form action='' id="change-price-form">

    </form>
</div>
{{--关闭订单--}}
<div class="trade_close_bombbox">
</div>

{{--评价--}}
<div class="revise_evaluate_bombbox" id='evaluate_bombbox'>
</div>

@include('web.user.seller.common.shipments', ['express_company' => $express_company])
@include('web.layout.footer')
</body>
{{--<script>PDFObject.embed("https://pdfobject.com/pdf/sample-3pp.pdf", ".contract_right");</script>--}}
<script>
    //url定义
    var express_url = "/member/seller/orders/{id}/order_express/0";
    var change_price_url = '/member/seller/orders/{id}/order_products/0/edit';
    var comment_url = '/member/seller/orders/{id}/user_comment/0';
    var order_update_edit = '/member/seller/orders/{id}/edit';

    $(function(){
        //修改价格
        $('.modify_price').click(function(){
            var id = $(this).data('id');
            var url = change_price_url.replace('{id}', id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.revise_price_bombbox form').html(data);
                    $('.revise_price_bombbox').show();
                    $('.bg_h').show();
                }
            });
        });

        //发货
        $('.shipments_btn').click(function(){
            var order_id = $(this).data('id');
            $('.express_confirm').data('id', order_id);
            $('.delivery_bombbox').show();
            $('.bg_h').show();
        });

        //查看物流信息
        $('.btn_seeLogistics').click(function(){
            var order_id = $(this).data('id');
            var url = express_url.replace('{id}', order_id);
            $('.bg_h').show();
            $.get(
                url,
                {},
                function (data) {
                    $('html').append(data);
                }
            );
        });


        //查看合同
        $('.btn_contract').click(function(){
            var id = $(this).attr('data-id');
            $('.bg_h').show();
            $('.contract_bombbox').show();
        });
        $('.close_box').click(function(){
            $('.bg_h').hide();
            $('.logistics_bombbox').hide();
            $('.contract_bombbox').hide();
            $('.revise_price_bombbox').hide();
            $('#evaluate_bombbox').hide();
            $('#see_evaluate_bombbox').hide();
            $('.delivery_bombbox').hide();
            $('.trade_close_bombbox').hide();
        });

        //确定关闭交易
        $(".trade_close").on('click', function(event) {
            var order_id = $(this).data('id');
            var url = order_update_edit.replace('{id}', order_id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.trade_close_bombbox').html(data);
                    $('.trade_close_bombbox').show();
                    $('.bg_h').show();
                }
            });
        });

        //评价
        $('.revise_evaluate').click(function(){
            var order_id = $(this).data('id');
            var url = comment_url.replace('{id}', order_id);
            $.ajax({
                url: url,
                type: 'get',
                dataType: 'html',
                success: function (data) {
                    $('.revise_evaluate_bombbox').html(data);
                    $('.revise_evaluate_bombbox').show();
                    $('.bg_h').show();
                }
            });
        });
    });
</script>
</html>